#include<iostream>
#include<time.h>
#include<chrono>
using namespace std;
using namespace chrono;

#define N 1000
double a[N], b[N][N], sum[N];
int i, j;

void create(int n)
{
	for (i = 0; i < n; i++)
	{
		a[i] = i;
		for (j = 0; j < n; j++)
			b[i][j] = i + j;
	}
}

void f1(int n)
{

	for (i = 0; i < n; i++) {
		sum[i] = 0.0;
		for (j = 0; j < n; j++)
			sum[i] += b[j][i] * a[j];
	}



}

void f2(int n)
{
	for (i = 0; i < n; i++)
		sum[i] = 0.0;
	for (j = 0; j < n; j++)
		for (i = 0; i < n; i++)
			sum[i] += b[j][i] * a[j];
}

int main()
{
	create(N);
	typedef std::chrono::high_resolution_clock Clock;
	auto t1 = Clock::now();
	for (int i = 0; i < 100; i++)
	{
		f1(N);
		//f2(N);
	}
	auto t2 = Clock::now();
	std::cout << std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count() /100<< endl;
}